// 后台路由

const express = require('express');
const router = express.Router();


//引入后台控制器
const adminController = require('../controllers/adminController');

// --------------------页面的显示路由--------------------------------------
router.get('/',adminController.index);

router.get('/login',adminController.loginPage);

router.post('/login',adminController.login);

router.get('/logout',adminController.logout);

//显示用户管理界面
router.get('/listuser',adminController.listuser)
//网站菜单界面
router.get('/menu',adminController.menu)
// 文章分类
router.get('/class',adminController.class)

//文章管理界面
router.get('/artical',adminController.artical)
//轮播图管理界面
router.get('/banner',adminController.banner)

// --------------------用户路由--------------------------------------

router.get('/addUser',adminController.addUserPage);

router.post('/addUser',adminController.addUser);



router.post('/addAgent',adminController.addAgent);

router.get('/editUser/:id',adminController.getOneUser);

router.post('/editUser',adminController.editUser);

router.get('/deleteUser/:id',adminController.deleteUser)

router.post('/search',adminController.search);

// --------------------菜单路由--------------------------------------
router.get('/addMenuPage',adminController.addMenuPage);

router.post('/addMenu',adminController.addMenu);

router.get('/editMenu/:id',adminController.getOneMenu);

router.post('/editMenu',adminController.editMenu);

router.get('/deleteMenu/:id',adminController.deleteMenu)

// --------------------菜单路由--------------------------------------
router.get('/addClass',adminController.addClassPage);

router.post('/addClass',adminController.addClass);

router.get('/editClass/:id',adminController.getOneClass);

router.post('/editClass',adminController.editClass);

router.get('/deleteClass/:id',adminController.deleteClass)

// --------------------轮播图路由--------------------------------------
router.get('/addBanner',adminController.addBannerPage);

const upload = require('../utils/upload');
router.post('/addBanner',upload.single('banner'),adminController.addBanner);

router.get('/editBanner/:id',adminController.getOneBanner);

router.post('/editBanner',upload.single('banner'),adminController.editBanner);

router.get('/deleteBanner/:id',adminController.deleteBanner);





//添加文章
router.get('/addArtical',adminController.addArticalPage);

router.post('/addArtical',adminController.addArtical);

router.get('/editAtical/:id',adminController.getOneArtical);

router.post('/editArtical',adminController.editArtical);

router.get('/deleteAtical/:id',adminController.deleteArtical);


module.exports = router;